<template>
<div>
  到账银行卡:
  <select name="" id="" v-for="i in list" :key="i" v-model="mode" style="width: 120px;height: 30px">
    <option :value="i.card_number">{{ i.card_name }}</option>
  </select>
  <div style="font-size: 2px">&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;2个小时到账</div>
  <br>
  <div style="font-size: 15px">提现金额&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;</div>
 <div>
    <div><van-field style="width: 100px;background-color: aliceblue;" v-model="price"></van-field></div>
    <div style="font-size: 15px">当前账户余额为{{list2['money']}}元&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;</div>
   <van-button @click="tixian">提现</van-button>
 </div>
  <van-popup v-model:show="show_hours" closeable close-icon="close" :style="{ height: '60%' ,width: '30%' }">
    <center><h1>请输入提现密码</h1>
      <h3>提现{{this.price}}到账户余额中</h3></center>
    <van-field v-model="password" type="password" label="密码" style="width: 50%;border: 1px"  />
    <div style="font-size: 10px" v-if="this.price<10">费率为0.10% 最低0.10%</div>
    <div style="font-size: 10px" v-else>费率为{{price*0.0001}}</div>
    <van-button @click="queren">确认</van-button>
  </van-popup>
</div>
</template>

<script>
export default {
name: "withdrawals",
  data(){
  return{
    list: [],
    list2: [],
    uid:localStorage.getItem('usrid'),
    price:0,
    password:'',
    show_hours:false,
    mode:'',
    price_pas:''
  }
  },
  methods:{
    tixian(){
      this.show_hours=true
    },
    queren(){
      this.myaxios('http://localhost:5000/get_user', 'get', {
        'uid': localStorage.getItem('usrid'),
        'code': this.password,
      })
          .then(res => {
            console.log(res)
            if (res.code=='200'){
              if (this.price<10){
                console.log('11111')
                this.price_pas=this.price+0.0001
              }else {
                console.log(this.price*0.0001)
                this.price_pas=this.price*0.0001
                this.price_pas=this.price_pas+Number(this.price)
              }
              this.myaxios('http://localhost:5000/withdrawal', 'post', {
                  'user_id': localStorage.getItem('usrid'),
                'mode': this.mode,
                'price': this.price_pas,
                'password': this.password,
              })
                  .then(res => {
                    console.log(res)
                    if (res.code==200){
                      this.list2['money']=Number(this.list2['money'])-Number(this.price)
                      this.show_hours=false
                    }
                  })
            }else {
              alert(res.msg)
            }
          })
    },
    // 获取数据
    git_data(){
      console.log(this.uid)
      this.myaxios('http://localhost:5000/personal_information','get',{'uid':this.uid}).then(res=>{
        console.log(res)
        this.list2=res.list
      })
    },

    get_ban() {
      this.myaxios('http://localhost:5000/get_bank_card', 'get', {'uid': localStorage.getItem('usrid')})
          .then(res => {
            console.log(res)
            this.list = res.data
          })
    }
  },
  mounted() {
this.get_ban()
this.git_data()
  }
}
</script>

<style scoped>

</style>
